/*
 * @Descripttion:
 * @version: 1.0.0
 * @Author: liuzicheng
 * @Date: 2025-01-21 11:19:39
 * @LastEditors: liuzicheng
 * @LastEditTime: 2025-02-25 16:14:59
 */
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'
import presetRemToPx from '@unocss/preset-rem-to-px'
import { defineConfig, presetAttributify, presetIcons, presetUno } from 'unocss'
import { getIcons } from './build/index.js'
import presetLegacyCompat from '@unocss/preset-legacy-compat'

const icons = getIcons()
export default defineConfig({
	presets: [
		presetUno(),
		presetAttributify(),
		presetLegacyCompat({
      // 选项
      commaStyleColorFunction: true,
      legacyColorSpace: true
    }),
		presetIcons({
			warn: true,
			prefix: ['i-'],
			extraProperties: {
				display: 'inline-block',
				width: '1em',
				height: '1em',
			},
			collections: {
				me: FileSystemIconLoader('./src/assets/icons/isme', svg => {
					return	svg.replace(/#([0-9a-fA-F]{3}){1,2}\b/g, 'currentColor')
				}
				),

			},
		}),
		presetRemToPx({ baseFontSize: 4 }),
	],
	// 避免没有引用的图片被删除
	safelist: icons.map(icon => `${icon} ${icon}?mask`.split(' ')).flat(),
	shortcuts: {
		'switch-animation': 'transition duration-300',
		'bg-base': 'bg-[#f0f0f0] dark:bg-[#20202a] switch-animation',
		'card-base': 'bg-[#ffffff] dark:bg-[#10101a] switch-animation',
		'text-base': 'text-[#20202a] dark:text-[#f0f0f0] switch-animation',
		'switch-label-base': 'bg-gray-200 dark:bg-gray-800 switch-animation',
		'switch-span-base': 'bg-white dark:bg-gray-300 switch-animation',
		'wh-full': 'w-full h-full',
		'f-c-c': 'flex justify-center items-center',
		'f-dc-c': 'flex flex-col justify-center items-center',
		'flex-col': 'flex flex-col',
		'card-border': 'border border-solid border-light_border dark:border-dark_border',
		'auto-bg': 'bg-white dark:bg-dark',
		'auto-bg-hover': 'hover:bg-#eaf0f1 hover:dark:bg-#1b2429',
		'auto-bg-highlight': 'bg-#eaf0f1 dark:bg-#1b2429',
		'text-highlight': 'rounded-4 px-8 py-2 auto-bg-highlight',
		"transition": "transition-all duration-300 ease-in-out",
		"a-box-style":"bg-#4096ff dark-text-#fff text-#fff",
		"normal-box-style":"bg-#f5f5f5 dark-bg-#141414  dark-text-#999999",
	},
	rules: [
		// [
		// 	/^m(l?r?t?b?)-(\d+)$/, ([, d]) => ({ margin: `${Number(d) / 4}rem` })
		// ],
	],
})